
import React,{Suspense, lazy } from 'react'
import {HashRouter as Hash,useRoutes,Navigate } from 'react-router-dom'
import Loading from '../components/Loading'

import StartRoutes from './start/routes'
import ErrorRoutes from './errors/routes'
import HomeRoutes from './home/routes'
import Guideroutes from "./guide/routes"
import ChangePassroutes from './changepass/routes'
import Settroutes from './sett/routes'
import Detailedroutes from "./detailed/routes"
import MyAdviseroutes from './myadvise/routes'



export default function Mainindex() {
  return (
    <div className='mains'>
        <LayoutConfig></LayoutConfig>
    </div>
  )
}

const LayoutConfig =()=>{
    return(
        <Hash>
            <Suspense fallback={Loading()}>
                <RouterIndex></RouterIndex>
            </Suspense>
        </Hash>
    )
}

const RouterIndex =()=>{
    const elements=useRoutes([
        {
            path:"/",
            element:<Navigate replace to='/guide'/>
        },
        ...ErrorRoutes,
        ...StartRoutes,
        ...HomeRoutes,
        ...Guideroutes,
        ...ChangePassroutes,
        ...Settroutes,
        ...Detailedroutes,
        ...MyAdviseroutes,
        {
            path:"*",
            element:<Navigate replace to='/404'/>
        }

    ])
    return elements
}